[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
operator operator Type
operator operator_symbol(parameters) {statements;}
The operator keyword allows you to overload (i.e. customize the
deifinition for your objects) the action of a given operator. The
operators << and >> are already overloaded in C++. The only operators
you cannot overload are:
?: . :: .* ->*
-------------------------------- Example ---------------------------------
This example overloads the + operator to work on complex numbers.
complex operator+ (complex conum1, complex conum2)
{
return complex(conum1.real+conum2.real, c1onum.imag+conum2.imag);
}
See Also:
class
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson